package cn.video;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;


public class Getdata {
	   private static Connection con;
	   private static Statement sql;
	   private static ResultSet res;
	   
	   
	   Connection getConnection(){
	         try {
	            Class.forName("com.mysql.jdbc.Driver");
	            System.out.println("数据库驱动加载成功！");
	        }catch (ClassNotFoundException e){
	            e.printStackTrace();
	        }
	         try {
				 con = DriverManager.getConnection("jdbc:mysql:"+"//localhost:3306/dbsheep","root","root");
	            System.out.println("数据库连接成功！");
	        }catch (SQLException e){
	            e.printStackTrace();
	        }
	        return con;
	    }
	     
	public List geturl(String deviceid) {

		Getdata ts = new Getdata();
        ts.getConnection();
        List lists = new ArrayList();
		videoUrl point = new videoUrl();
        try {
            sql = con.createStatement();
//            res = sql.executeQuery("select * from fr_camera " );
 			res = sql.executeQuery("select * from fr_camera where number  = "+"'"+deviceid+"'" );
            while (res.next()){
				String rtmpUrl   =  res.getString("rtmpUrl");
                String hlsUrl   =  res.getString("hlsUrl");
				String picUrl   =  res.getString("picUrl");


				System.out.println("  rtmpUrl：  " + rtmpUrl );

				point.setrtmpUrl(rtmpUrl);
				point.sethlsUrl(hlsUrl);
				point.setpicUrl(picUrl);

                lists.add(point);
            }
            return lists;
        }catch (Exception e){
            e.printStackTrace();
        }
    
		return null;
		
	}
	
	 
	
	 
}
